package de.gwtprime.shared.util;

import com.google.gwt.regexp.shared.MatchResult;
import com.google.gwt.regexp.shared.RegExp;

public class LoginHelper {

	
	public static boolean isPasswordValid(String password){
		
		if(password == null) return false;
		if(password.length()<AppUtilsShared.minimumPasswordLength) return false;
		if(password.length()>AppUtilsShared.maximumPasswordLength) return false;
		
		return true;
	}
	
	
	public static boolean isUserNameValid(String userName){
		
		if(userName == null) return false;
		if(userName.length()<AppUtilsShared.minimumUserNameLength) return false;
		if(userName.length()>AppUtilsShared.maximumUserNameLength) return false;
		return true;
	}
	
	/**
	 * Validate if we have a valid email
	 */
	public static boolean isValidEmail(String email){
		
		RegExp regExp = RegExp.compile(AppUtilsShared.EMAIL_PATTERN);
		MatchResult matcher = regExp.exec(email);
		boolean matchFound = (matcher != null); // equivalent to regExp.test(inputStr); 

		return matchFound;
	}
}
